from multiprocessing import cpu_count

bind = ['127.0.0.1:8888']  # 线上环境不会开启在公网IP下，一般使用内网IP
daemon = True  # 是否开启守护进程模式
pidfile = 'logs/gunicorn.pid'

workers = cpu_count() * 2
worker_class = 'gevent'  # 指定一个异步处理的库
worker_connections = 65535

keepalive = 60
timeout = 30
graceful_timeout = 10
forwarded_allow_ips = '*'

# 日志处理
capture_output = True
loglevel = 'info'
errorlog = 'logs/error.log'

# 启动方式
# gunicorn -c project/gunicorn-config.py project.wsgi

# linux 文件描述符
# ulimit -n     修改文件描述符 ulimit -n 65535
# kill `cat gunicorn.pid`
# kill -HUP `cat gunicorn.pid`   不间断重启
# netstat nat | grep 8888
# watch -n 0.5 `cat gunicorn.pid`    每隔0.5秒执行以下后面的命令

# 压力测试
# apt-get install apache2-utils
# ab -n 1000 -c 100 http://127.0.0.1:8888/
